<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>cgebrd.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CGEBRD.1"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a>( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK,
     $                   INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      INTEGER            INFO, LDA, LWORK, M, N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      REAL               D( * ), E( * )
      COMPLEX            A( LDA, * ), TAUP( * ), TAUQ( * ),
     $                   WORK( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CGEBRD.20"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a> reduces a general complex M-by-N matrix A to upper or lower
</span><span class="comment">*</span><span class="comment">  bidiagonal form B by a unitary transformation: Q**H * A * P = B.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  If m &gt;= n, B is upper bidiagonal; if m &lt; n, B is lower bidiagonal.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  M       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of rows in the matrix A.  M &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of columns in the matrix A.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A       (input/output) COMPLEX array, dimension (LDA,N)
</span><span class="comment">*</span><span class="comment">          On entry, the M-by-N general matrix to be reduced.
</span><span class="comment">*</span><span class="comment">          On exit,
</span><span class="comment">*</span><span class="comment">          if m &gt;= n, the diagonal and the first superdiagonal are
</span><span class="comment">*</span><span class="comment">            overwritten with the upper bidiagonal matrix B; the
</span><span class="comment">*</span><span class="comment">            elements below the diagonal, with the array TAUQ, represent
</span><span class="comment">*</span><span class="comment">            the unitary matrix Q as a product of elementary
</span><span class="comment">*</span><span class="comment">            reflectors, and the elements above the first superdiagonal,
</span><span class="comment">*</span><span class="comment">            with the array TAUP, represent the unitary matrix P as
</span><span class="comment">*</span><span class="comment">            a product of elementary reflectors;
</span><span class="comment">*</span><span class="comment">          if m &lt; n, the diagonal and the first subdiagonal are
</span><span class="comment">*</span><span class="comment">            overwritten with the lower bidiagonal matrix B; the
</span><span class="comment">*</span><span class="comment">            elements below the first subdiagonal, with the array TAUQ,
</span><span class="comment">*</span><span class="comment">            represent the unitary matrix Q as a product of
</span><span class="comment">*</span><span class="comment">            elementary reflectors, and the elements above the diagonal,
</span><span class="comment">*</span><span class="comment">            with the array TAUP, represent the unitary matrix P as
</span><span class="comment">*</span><span class="comment">            a product of elementary reflectors.
</span><span class="comment">*</span><span class="comment">          See Further Details.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array A.  LDA &gt;= max(1,M).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  D       (output) REAL array, dimension (min(M,N))
</span><span class="comment">*</span><span class="comment">          The diagonal elements of the bidiagonal matrix B:
</span><span class="comment">*</span><span class="comment">          D(i) = A(i,i).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  E       (output) REAL array, dimension (min(M,N)-1)
</span><span class="comment">*</span><span class="comment">          The off-diagonal elements of the bidiagonal matrix B:
</span><span class="comment">*</span><span class="comment">          if m &gt;= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
</span><span class="comment">*</span><span class="comment">          if m &lt; n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  TAUQ    (output) COMPLEX array dimension (min(M,N))
</span><span class="comment">*</span><span class="comment">          The scalar factors of the elementary reflectors which
</span><span class="comment">*</span><span class="comment">          represent the unitary matrix Q. See Further Details.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  TAUP    (output) COMPLEX array, dimension (min(M,N))
</span><span class="comment">*</span><span class="comment">          The scalar factors of the elementary reflectors which
</span><span class="comment">*</span><span class="comment">          represent the unitary matrix P. See Further Details.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace/output) COMPLEX array, dimension (MAX(1,LWORK))
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LWORK   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The length of the array WORK.  LWORK &gt;= max(1,M,N).
</span><span class="comment">*</span><span class="comment">          For optimum performance LWORK &gt;= (M+N)*NB, where NB
</span><span class="comment">*</span><span class="comment">          is the optimal blocksize.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If LWORK = -1, then a workspace query is assumed; the routine
</span><span class="comment">*</span><span class="comment">          only calculates the optimal size of the WORK array, returns
</span><span class="comment">*</span><span class="comment">          this value as the first entry of the WORK array, and no error
</span><span class="comment">*</span><span class="comment">          message related to LWORK is issued by <a name="XERBLA.84"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit.
</span><span class="comment">*</span><span class="comment">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Further Details
</span><span class="comment">*</span><span class="comment">  ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The matrices Q and P are represented as products of elementary
</span><span class="comment">*</span><span class="comment">  reflectors:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  If m &gt;= n,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Each H(i) and G(i) has the form:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u'
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where tauq and taup are complex scalars, and v and u are complex
</span><span class="comment">*</span><span class="comment">  vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in
</span><span class="comment">*</span><span class="comment">  A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in
</span><span class="comment">*</span><span class="comment">  A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  If m &lt; n,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Each H(i) and G(i) has the form:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u'
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where tauq and taup are complex scalars, and v and u are complex
</span><span class="comment">*</span><span class="comment">  vectors; v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in
</span><span class="comment">*</span><span class="comment">  A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in
</span><span class="comment">*</span><span class="comment">  A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The contents of A on exit are illustrated by the following examples:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  m = 6 and n = 5 (m &gt; n):          m = 5 and n = 6 (m &lt; n):
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 )
</span><span class="comment">*</span><span class="comment">    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 )
</span><span class="comment">*</span><span class="comment">    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 )
</span><span class="comment">*</span><span class="comment">    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 )
</span><span class="comment">*</span><span class="comment">    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 )
</span><span class="comment">*</span><span class="comment">    (  v1  v2  v3  v4  v5 )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where d and e denote diagonal and off-diagonal elements of B, vi
</span><span class="comment">*</span><span class="comment">  denotes an element of the vector defining H(i), and ui an element of
</span><span class="comment">*</span><span class="comment">  the vector defining G(i).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      COMPLEX            ONE
      PARAMETER          ( ONE = ( 1.0E+0, 0.0E+0 ) )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            LQUERY
      INTEGER            I, IINFO, J, LDWRKX, LDWRKY, LWKOPT, MINMN, NB,
     $                   NBMIN, NX
      REAL               WS
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="CGEBD2.150"></a><a href="cgebd2.f.html#CGEBD2.1">CGEBD2</a>, CGEMM, <a name="CLABRD.150"></a><a href="clabrd.f.html#CLABRD.1">CLABRD</a>, <a name="XERBLA.150"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX, MIN, REAL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      INTEGER            <a name="ILAENV.156"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
      EXTERNAL           <a name="ILAENV.157"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      NB = MAX( 1, <a name="ILAENV.164"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="CGEBRD.164"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a>'</span>, <span class="string">' '</span>, M, N, -1, -1 ) )
      LWKOPT = ( M+N )*NB
      WORK( 1 ) = REAL( LWKOPT )
      LQUERY = ( LWORK.EQ.-1 )
      IF( M.LT.0 ) THEN
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
         INFO = -2
      ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
         INFO = -4
      ELSE IF( LWORK.LT.MAX( 1, M, N ) .AND. .NOT.LQUERY ) THEN
         INFO = -10
      END IF
      IF( INFO.LT.0 ) THEN
         CALL <a name="XERBLA.178"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CGEBRD.178"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a>'</span>, -INFO )
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      MINMN = MIN( M, N )
      IF( MINMN.EQ.0 ) THEN
         WORK( 1 ) = 1
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span>      WS = MAX( M, N )
      LDWRKX = M
      LDWRKY = N
<span class="comment">*</span><span class="comment">
</span>      IF( NB.GT.1 .AND. NB.LT.MINMN ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Set the crossover point NX.
</span><span class="comment">*</span><span class="comment">
</span>         NX = MAX( NB, <a name="ILAENV.200"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 3, <span class="string">'<a name="CGEBRD.200"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a>'</span>, <span class="string">' '</span>, M, N, -1, -1 ) )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Determine when to switch from blocked to unblocked code.
</span><span class="comment">*</span><span class="comment">
</span>         IF( NX.LT.MINMN ) THEN
            WS = ( M+N )*NB
            IF( LWORK.LT.WS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Not enough work space for the optimal NB, consider using
</span><span class="comment">*</span><span class="comment">              a smaller block size.
</span><span class="comment">*</span><span class="comment">
</span>               NBMIN = <a name="ILAENV.211"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 2, <span class="string">'<a name="CGEBRD.211"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a>'</span>, <span class="string">' '</span>, M, N, -1, -1 )
               IF( LWORK.GE.( M+N )*NBMIN ) THEN
                  NB = LWORK / ( M+N )
               ELSE
                  NB = 1
                  NX = MINMN
               END IF
            END IF
         END IF
      ELSE
         NX = MINMN
      END IF
<span class="comment">*</span><span class="comment">
</span>      DO 30 I = 1, MINMN - NX, NB
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Reduce rows and columns i:i+ib-1 to bidiagonal form and return
</span><span class="comment">*</span><span class="comment">        the matrices X and Y which are needed to update the unreduced
</span><span class="comment">*</span><span class="comment">        part of the matrix
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="CLABRD.230"></a><a href="clabrd.f.html#CLABRD.1">CLABRD</a>( M-I+1, N-I+1, NB, A( I, I ), LDA, D( I ), E( I ),
     $                TAUQ( I ), TAUP( I ), WORK, LDWRKX,
     $                WORK( LDWRKX*NB+1 ), LDWRKY )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Update the trailing submatrix A(i+ib:m,i+ib:n), using
</span><span class="comment">*</span><span class="comment">        an update of the form  A := A - V*Y' - X*U'
</span><span class="comment">*</span><span class="comment">
</span>         CALL CGEMM( <span class="string">'No transpose'</span>, <span class="string">'Conjugate transpose'</span>, M-I-NB+1,
     $               N-I-NB+1, NB, -ONE, A( I+NB, I ), LDA,
     $               WORK( LDWRKX*NB+NB+1 ), LDWRKY, ONE,
     $               A( I+NB, I+NB ), LDA )
         CALL CGEMM( <span class="string">'No transpose'</span>, <span class="string">'No transpose'</span>, M-I-NB+1, N-I-NB+1,
     $               NB, -ONE, WORK( NB+1 ), LDWRKX, A( I, I+NB ), LDA,
     $               ONE, A( I+NB, I+NB ), LDA )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Copy diagonal and off-diagonal elements of B back into A
</span><span class="comment">*</span><span class="comment">
</span>         IF( M.GE.N ) THEN
            DO 10 J = I, I + NB - 1
               A( J, J ) = D( J )
               A( J, J+1 ) = E( J )
   10       CONTINUE
         ELSE
            DO 20 J = I, I + NB - 1
               A( J, J ) = D( J )
               A( J+1, J ) = E( J )
   20       CONTINUE
         END IF
   30 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Use unblocked code to reduce the remainder of the matrix
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="CGEBD2.262"></a><a href="cgebd2.f.html#CGEBD2.1">CGEBD2</a>( M-I+1, N-I+1, A( I, I ), LDA, D( I ), E( I ),
     $             TAUQ( I ), TAUP( I ), WORK, IINFO )
      WORK( 1 ) = WS
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CGEBRD.267"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
